home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Utilities / NPoff / Source / NPoff_main.m < prev    next >
Text File  |  1994-03-19  |  1KB  |  66 lines

  1. /* 
  2.  * This file is not to be maintained by ProjectBuilder!
  3.  *
  4.  * Application: NPoff
  5.  *
  6.  * Purpose: To power down an attached NeXT laser printer.
  7.  *
  8.  * Author: Christopher Rath     crath@bnr.ca    (613) 824-4584
  9.  *         Box 15781, Station 'F'
  10.  *         Ottawa, ON   CANADA
  11.  *         K1C 3S7
  12.  *
  13.  * Version: 1.0
  14.  *
  15.  * Written: 18 March, 1994
  16.  *
  17.  * Bugs: Doesn't advertise itself as a service.
  18.  *
  19.  * Copyright: None.
  20.  *            Released to the public domain.
  21.  */
  22.  
  23. #import <appkit/appkit.h>
  24. #import <errno.h>
  25. #import <string.h>
  26. #import <sys/file.h>
  27.  
  28.  
  29. /*
  30.  * Contants:
  31.  *
  32.  * NPPOWER - The UNIX command used to control power to the NeXT printer.
  33.  * OFF - The parameter to pass to NPPOWER to turn off the printer.
  34.  * ON - The parameter to pass to NPPOWER to turn on the printer.
  35.  */
  36. #define NPPOWER "/usr/etc/nppower"
  37. #define OFF     "off"
  38. #define ON      "on"
  39.  
  40.  
  41. void main(int argc, char *argv[])
  42. {
  43.     [Application new];
  44.  
  45.     if (access(NPPOWER, F_OK | X_OK))
  46.     {
  47.         /* 
  48.          * Some Error occured, put up an alert box informing the user.
  49.          */ 
  50.         NXRunAlertPanel([NXApp appName],
  51.                         "Unable to execute %s to power down the NeXT printer: %s (%d).",
  52.                         "Cancel", NULL, NULL,
  53.                         NPPOWER, strerror(errno), errno);
  54.     }
  55.     else
  56.     {
  57.         /*
  58.          * Access() says we can execute NPPOWER, so let's do it.
  59.          */
  60.         system(NPPOWER " " OFF);
  61.     }
  62.     
  63.     [NXApp free];
  64.     exit(0);
  65. }
  66.